﻿using System.Windows;

namespace GUI.Custom_Classes
{
    /// <summary>
    /// Interaction logic for Hilighter_Box.xaml
    /// </summary>
    public partial class Hilighter_Box : Window
    {
        private static Hilighter_Box instance;
        public static Hilighter_Box Singleton { get {
            if (instance == null)
                instance = new Hilighter_Box();
            return instance;
        } }

        public Hilighter_Box()
        {
            InitializeComponent();
        }

        public void Target(Rect elementRectangle)
        {
            // Left bound
            if (elementRectangle.Left.Equals(double.NegativeInfinity) || elementRectangle.Left.Equals(double.PositiveInfinity))
            {
                this.Left = 1;
            }
            else
            {
                this.Left = elementRectangle.Left - 4;
            }

            // Top bound
            if (elementRectangle.Top.Equals(double.NegativeInfinity) || elementRectangle.Top.Equals(double.PositiveInfinity))
            {
                this.Top = 1;
            }
            else
            {
                this.Top = elementRectangle.Top - 4;
            }

            // Height
            if (elementRectangle.Height.Equals(double.NegativeInfinity) || elementRectangle.Height.Equals(double.PositiveInfinity))
            {
                this.Height = 1;
            }
            else
            {
                this.Height = elementRectangle.Height + 8;
            }

            // Width
            if (elementRectangle.Width.Equals(double.NegativeInfinity) || elementRectangle.Width.Equals(double.PositiveInfinity))
            {
                this.Width = 1;
            }
            else
            {
                this.Width = elementRectangle.Width + 8;
            }

            this.Focusable = false;
            this.Show();
        }
    }
}
